using System;
using System.Drawing;
using HRM.BLL;
using HRM.DAL.DAO;
using HRM.DAL.Report;

namespace HRM.UI.HRManagerUI.Profile
{
    public partial class HomeHM : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if(!IsPostBack)
            {
               
                GetEmployeeInfo();
                CountUnRead();
                GetNotice();
            }
        }

        private void CountUnRead()
        {
            ApplicationManager manager = new ApplicationManager();
            int unread = manager.CountUnReadApplication();
            MessageManager messageManager=new MessageManager();
            Code code=new Code();
            code.CodeName = Session["Code"].ToString();
            unreadLbl.ForeColor = Color.Red;
            unreadLbl.Text = unread.ToString();
            unReadMsg.ForeColor = Color.Red;
            unReadMsg.Text = messageManager.CountUnRead(code).ToString();
          
        }

        private void GetEmployeeInfo()
        {
            Code code = new Code();
            code.CodeName = Session["Code"].ToString();
            EmployeeManager manager=new EmployeeManager();
            ViewEmployee viewEmployee=new ViewEmployee();
            viewEmployee = manager.SearchEmployeeByCode(code);
            Session["name"] = viewEmployee.Employee.Name;
            //userNameLbl.Text = viewEmployee.Employee.Name;
            empImage.ImageUrl = viewEmployee.Photo.FileName;
            //userDesignation.Text = viewEmployee.Designation.Title;
            //joinDate.Text = (viewEmployee.Employee.JoiningDate).ToShortDateString();
            //empCode.Text = code.CodeName;
        }

        private void GetNotice()
        {
            NoticeManager manager = new NoticeManager();
            int i = 0;
            foreach (Notice notice in manager.GetAllNotices())
            {
                if (i == 0)
                {
                    NoticeTitle.Text = notice.Subject;
                }
                i++;
            }
        }
    }
}